﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Clinica_Frba.AbmdeRol
{
    public partial class Baja : Form
    {
        public Baja()
        {
            InitializeComponent();
            string comando;
            SqlConnection myConnection = new SqlConnection(publico.ConnectionString);
            myConnection.Open();
            comando = "SELECT * FROM DUNDER_MIFFLIN.ROL WHERE ESTADO='H'";
            SqlDataAdapter da = new SqlDataAdapter(comando, myConnection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }
        





        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            int ide;
            SqlConnection myConnection = new SqlConnection(publico.ConnectionString);
            myConnection.Open();
            foreach (DataGridViewRow row in dataGridView1.SelectedRows)
            {
                ide = Convert.ToInt32(row.Cells[0].Value);
                SqlCommand borr = new SqlCommand("DELETE FROM DUNDER_MIFFLIN.ROL_USUARIO WHERE ID_ROL=" + ide, myConnection);
                borr.ExecuteNonQuery();
                SqlCommand inh = new SqlCommand("UPDATE DUNDER_MIFFLIN.ROL SET ESTADO='I' WHERE ID_ROL=" + ide, myConnection);
                inh.ExecuteNonQuery();
            }
            string comando;
            comando = "SELECT * FROM DUNDER_MIFFLIN.ROL WHERE ESTADO='H'";
            SqlDataAdapter da = new SqlDataAdapter(comando, myConnection);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dataGridView1.DataSource = dt;
        }

        private void Baja_Load(object sender, EventArgs e)
        {

        }
    }
}
